package com.wyx.controller.system;

import com.wyx.dto.OperLogDto;
import com.wyx.service.OperLogService;
import com.wyx.vo.AjaxResult;
import com.wyx.vo.DataGridView;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;

/**
 * @author xiaoxiong
 * @version 1.0
 * @date 2021/3/1 15:41
 */

@RestController
@RequestMapping("system/operLog")
@Log4j2
public class OperLogController {
    @Autowired
    private OperLogService operLogService;

    /**
     * 列表分页查询
     * @param operLogDto
     * @return
     */
    @GetMapping("/listForPage")
    public AjaxResult listForPage(OperLogDto operLogDto){
        DataGridView dataGridView = this.operLogService.listForPage(operLogDto);
        return AjaxResult.success("查询成功",dataGridView.getData(),dataGridView.getTotal());
    }


    /**
     * 根据ids删除日志
     * @param infoIds
     * @return
     */
    @DeleteMapping("/deleteOperLogByIds/{infoIds}")
    public AjaxResult deleteOperLogByIds(@PathVariable @Validated @NotEmpty(message = "infoIds不能为空") Long[] infoIds){
        return AjaxResult.toAjax(this.operLogService.deleteOperLogByIds(infoIds));
    }

    /**
     * 情况所有日志
     * @return
     */
    @DeleteMapping("clearAllOperLog")
    public AjaxResult deleteAll(){
        return AjaxResult.toAjax(this.operLogService.deleteAllOperLog());
    }


}
